<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            min-height: 100vh;
            display: grid; /* 网格*/
            justify-content: center;
            align-content: center;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
            line-height: 2;
            background-color: #ffc600;
        }
        .wrapper{
            width: 400px;
            height: 80vh;
            padding: 20px;
            border: 1px solid black;
            display: grid;
            grid-template-rows: 1fr auto;
        }
        button.accept{
            background-color: #ff0060;
            color: white;
            font-size: 1rem;
            padding: 20px;
            transition: all 0.2s;
        }
        button.accept[disabled] { 
            opacity: 0.2;
        }
        .items-and-condition{
            overflow: scroll;
            -webkit-overflow-scrolling: touch;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        <div class="items-and-condition">
            <p>声明</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <p>任务清单</p>
            <strong class="watch"></strong>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
            <p>提供APP内购买项目提供APP内购买项目提供APP内购买项目</p>
        </div>
        <button class="accept" disabled>Accept</button>
    </div>
    <script>
        /*
        (function(){
            const oAcceptbtn = document.querySelector('.accept');
        setTimeout(() =>{
            oAcceptbtn.removeAttribute('disabled')
        },2000)
        })() */
        (function(){
            const terms = document.querySelector('.items-and-condition'),
                watch = document.querySelector('.watch'),
                button = document.querySelector('.accept')
                function callback(payload){
                if(payload[0].intersectionRatio == 1){
                    button.removeAttribute('disabled')
                }
            }
            // IntersectionObserver() 视窗里面是否已经出现了
            const ob = new IntersectionObserver(callback,{
                root:terms,
                threshold:1
            });
            ob.observe(terms.getElementsByTagName('p')[terms.getElementsByTagName('p').length-1]);
        })()
    </script>
</body>
</html>